package com.kl.drs.util;


import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.MultimediaInfo;

import java.io.File;

/**
 * 视频文件工具类
 * @author WYN
 * 
 */
public class VideoFileUtils {
	public static int getVideoFileTime(String filePath){
		File source= new File(filePath);
	     Encoder encoder = new Encoder();
	     try {
	        MultimediaInfo multimediaInfo = encoder.getInfo(source);
	        int ls = (int) multimediaInfo.getDuration();
	       // System.out.println("此视频时长为:"+(ls)/1000+"秒！");
	        return ls/1000;
	     } catch(Exception e) {
	       e.printStackTrace();
	       Log4jUtils.logError("VideoFileUtils.getVideoFilePath()", "获取视频文件时长失败"+e.getMessage(), e);
	     }
		return 0;
	}
	public static void main(String[] args) {
		File file =new File("D:/公司文件/双录视频文件/VID_20180626_184116.mp4");
		System.out.println("大小："+file.length());
		System.out.println("时长："+VideoFileUtils.getVideoFileTime("D:/data/psbc/1012550.mp4"));
		
	}
}
